package mysql

import (
	"fmt"
	"time"
)
type User struct {
	Id int
	Username string `form:"username" json:"username" binding:"required,min=3,max=25"`
	Password string `form:"password" json:"password" binding:"required,min=6,max=25"`
	Salt string
	Createtime time.Time `xorm:"createtime created" json:"createtime" description:"创建时间"`
}


func (sink MysqlSink)GetUser(name string)(rows []User,err error) {
	model := make([]User, 0)
	err = sink.database.Where(" username = ?", name).Find(&model)
	if err !=nil{
		fmt.Println(err)
		return
	}
	return model,nil
}

//插入数据
func (sink MysqlSink) InsertUser(data User)(res int64,err error)  {
	affected, err :=sink.database.Insert(data)
	if err !=nil{
		fmt.Println(err)
		return
	}
	return affected,nil
}